/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package models;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Eduardo
 */
@Entity
@Table(name = "Detalle_Reserva_Cubiculo")
@NamedQueries({
    @NamedQuery(name = "DetalleReservaCubiculo.findAll", query = "SELECT d FROM DetalleReservaCubiculo d"),
    @NamedQuery(name = "DetalleReservaCubiculo.findByNumeroReservaCub", query = "SELECT d FROM DetalleReservaCubiculo d WHERE d.detalleReservaCubiculoPK.numeroReservaCub = :numeroReservaCub"),
    @NamedQuery(name = "DetalleReservaCubiculo.findByIdUsuario", query = "SELECT d FROM DetalleReservaCubiculo d WHERE d.detalleReservaCubiculoPK.idUsuario = :idUsuario"),
    @NamedQuery(name = "DetalleReservaCubiculo.findByEstado", query = "SELECT d FROM DetalleReservaCubiculo d WHERE d.estado = :estado")})
public class DetalleReservaCubiculo implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected DetalleReservaCubiculoPK detalleReservaCubiculoPK;
    @Column(name = "Estado")
    private Integer estado;
    @JoinColumn(name = "NumeroReservaCub", referencedColumnName = "NumeroReservaCub", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private ReservaCubiculo reservaCubiculo;
    @JoinColumn(name = "IdUsuario", referencedColumnName = "IdUsuario", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private UsuarioBiblioteca usuarioBiblioteca;

    public DetalleReservaCubiculo() {
    }

    public DetalleReservaCubiculo(DetalleReservaCubiculoPK detalleReservaCubiculoPK) {
        this.detalleReservaCubiculoPK = detalleReservaCubiculoPK;
    }

    public DetalleReservaCubiculo(int numeroReservaCub, int idUsuario) {
        this.detalleReservaCubiculoPK = new DetalleReservaCubiculoPK(numeroReservaCub, idUsuario);
    }

    public DetalleReservaCubiculoPK getDetalleReservaCubiculoPK() {
        return detalleReservaCubiculoPK;
    }

    public void setDetalleReservaCubiculoPK(DetalleReservaCubiculoPK detalleReservaCubiculoPK) {
        this.detalleReservaCubiculoPK = detalleReservaCubiculoPK;
    }

    public Integer getEstado() {
        return estado;
    }

    public void setEstado(Integer estado) {
        this.estado = estado;
    }

    public ReservaCubiculo getReservaCubiculo() {
        return reservaCubiculo;
    }

    public void setReservaCubiculo(ReservaCubiculo reservaCubiculo) {
        this.reservaCubiculo = reservaCubiculo;
    }

    public UsuarioBiblioteca getUsuarioBiblioteca() {
        return usuarioBiblioteca;
    }

    public void setUsuarioBiblioteca(UsuarioBiblioteca usuarioBiblioteca) {
        this.usuarioBiblioteca = usuarioBiblioteca;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (detalleReservaCubiculoPK != null ? detalleReservaCubiculoPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DetalleReservaCubiculo)) {
            return false;
        }
        DetalleReservaCubiculo other = (DetalleReservaCubiculo) object;
        if ((this.detalleReservaCubiculoPK == null && other.detalleReservaCubiculoPK != null) || (this.detalleReservaCubiculoPK != null && !this.detalleReservaCubiculoPK.equals(other.detalleReservaCubiculoPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "models.DetalleReservaCubiculo[ detalleReservaCubiculoPK=" + detalleReservaCubiculoPK + " ]";
    }
    
}
